home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Tutorial / Stepstone_Tutorial / fruitMain.m < prev    next >
Text File  |  1995-06-12  |  1KB  |  43 lines

  1. // Main program for testing the Fruit and Apple classes
  2.  
  3. #import "Fruit.h"
  4. #import "Apple.h"
  5.  
  6. main ( argc, argv )
  7. int argc;
  8. char *argv[];
  9. {
  10.     id aFruit, anApple;
  11.  
  12.     // Create a Fruit instance
  13.     aFruit = [ Fruit create ];
  14.     printf("aFruit, address %lx\n\t The diameter is %d and color is %s,\n",
  15.         aFruit,               //the address of AFruit
  16.         [ aFruit diameter ],
  17.         [ aFruit color ]);
  18.  
  19.     // grow the Fruit
  20.     [ aFruit grow ];
  21.     printf("aFruit, address %lx\n\t The diameter is %d and color is %s.\n",
  22.       aFruit,
  23.       [ aFruit diameter ],
  24.         [ aFruit color ]);
  25.         
  26.     // Create an Apple instance
  27.     anApple = [ Apple create ];
  28.     printf("anApple, address %lx\n\t The diameter is %d and color is %s,\n",
  29.         anApple,
  30.         [ anApple diameter ],  // address of anApple
  31.         [ anApple color ],
  32.         [ anApple flavor ]);
  33.  
  34.     // Change the apple's color flavor and diameter
  35.     [ [ [ anApple color: "red" ] flavor: "Macintosh" ] diameter: 7 ] ;
  36.     printf("anApple, address %lx\n\t The diameter is %d and color is %s.\n",
  37.       anApple,              // address of anApple
  38.         [ anApple diameter ],
  39.         [ anApple color ],
  40.         [ anApple flavor ]);
  41.  
  42. } // end of program
  43.